/*
 *
 *    Copyright (c) 2022 Project CHIP Authors
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

// THIS FILE IS GENERATED BY ZAP
// This file is generated from clusters-Structs.ipp.zapt

#include <clusters/CameraAvStreamManagement/Structs.h>

#include <app/data-model/StructDecodeIterator.h>
#include <app/data-model/WrappedStructEncoder.h>

namespace chip
{
namespace app
{
	namespace Clusters
	{
		namespace CameraAvStreamManagement
		{
			namespace Structs
			{

				namespace VideoResolutionStruct
				{
					CHIP_ERROR Type::Encode(TLV::TLVWriter &aWriter, TLV::Tag aTag) const
					{
						DataModel::WrappedStructEncoder encoder{ aWriter, aTag };
						encoder.Encode(to_underlying(Fields::kWidth), width);
						encoder.Encode(to_underlying(Fields::kHeight), height);
						return encoder.Finalize();
					}

					CHIP_ERROR DecodableType::Decode(TLV::TLVReader &reader)
					{
						detail::StructDecodeIterator __iterator(reader);
						while (true) {
							uint8_t __context_tag = 0;
							CHIP_ERROR err = __iterator.Next(__context_tag);
							VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV,
									    CHIP_NO_ERROR);
							ReturnErrorOnFailure(err);

							if (__context_tag == to_underlying(Fields::kWidth)) {
								err = DataModel::Decode(reader, width);
							} else if (__context_tag == to_underlying(Fields::kHeight)) {
								err = DataModel::Decode(reader, height);
							}

							ReturnErrorOnFailure(err);
						}
					}

				} // namespace VideoResolutionStruct

				namespace VideoStreamStruct
				{
					CHIP_ERROR Type::Encode(TLV::TLVWriter &aWriter, TLV::Tag aTag) const
					{
						DataModel::WrappedStructEncoder encoder{ aWriter, aTag };
						encoder.Encode(to_underlying(Fields::kVideoStreamID), videoStreamID);
						encoder.Encode(to_underlying(Fields::kStreamUsage), streamUsage);
						encoder.Encode(to_underlying(Fields::kVideoCodec), videoCodec);
						encoder.Encode(to_underlying(Fields::kMinFrameRate), minFrameRate);
						encoder.Encode(to_underlying(Fields::kMaxFrameRate), maxFrameRate);
						encoder.Encode(to_underlying(Fields::kMinResolution), minResolution);
						encoder.Encode(to_underlying(Fields::kMaxResolution), maxResolution);
						encoder.Encode(to_underlying(Fields::kMinBitRate), minBitRate);
						encoder.Encode(to_underlying(Fields::kMaxBitRate), maxBitRate);
						encoder.Encode(to_underlying(Fields::kMinKeyFrameInterval),
							       minKeyFrameInterval);
						encoder.Encode(to_underlying(Fields::kMaxKeyFrameInterval),
							       maxKeyFrameInterval);
						encoder.Encode(to_underlying(Fields::kWatermarkEnabled),
							       watermarkEnabled);
						encoder.Encode(to_underlying(Fields::kOSDEnabled), OSDEnabled);
						encoder.Encode(to_underlying(Fields::kReferenceCount), referenceCount);
						return encoder.Finalize();
					}

					CHIP_ERROR DecodableType::Decode(TLV::TLVReader &reader)
					{
						detail::StructDecodeIterator __iterator(reader);
						while (true) {
							uint8_t __context_tag = 0;
							CHIP_ERROR err = __iterator.Next(__context_tag);
							VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV,
									    CHIP_NO_ERROR);
							ReturnErrorOnFailure(err);

							if (__context_tag == to_underlying(Fields::kVideoStreamID)) {
								err = DataModel::Decode(reader, videoStreamID);
							} else if (__context_tag ==
								   to_underlying(Fields::kStreamUsage)) {
								err = DataModel::Decode(reader, streamUsage);
							} else if (__context_tag ==
								   to_underlying(Fields::kVideoCodec)) {
								err = DataModel::Decode(reader, videoCodec);
							} else if (__context_tag ==
								   to_underlying(Fields::kMinFrameRate)) {
								err = DataModel::Decode(reader, minFrameRate);
							} else if (__context_tag ==
								   to_underlying(Fields::kMaxFrameRate)) {
								err = DataModel::Decode(reader, maxFrameRate);
							} else if (__context_tag ==
								   to_underlying(Fields::kMinResolution)) {
								err = DataModel::Decode(reader, minResolution);
							} else if (__context_tag ==
								   to_underlying(Fields::kMaxResolution)) {
								err = DataModel::Decode(reader, maxResolution);
							} else if (__context_tag ==
								   to_underlying(Fields::kMinBitRate)) {
								err = DataModel::Decode(reader, minBitRate);
							} else if (__context_tag ==
								   to_underlying(Fields::kMaxBitRate)) {
								err = DataModel::Decode(reader, maxBitRate);
							} else if (__context_tag ==
								   to_underlying(Fields::kMinKeyFrameInterval)) {
								err = DataModel::Decode(reader, minKeyFrameInterval);
							} else if (__context_tag ==
								   to_underlying(Fields::kMaxKeyFrameInterval)) {
								err = DataModel::Decode(reader, maxKeyFrameInterval);
							} else if (__context_tag ==
								   to_underlying(Fields::kWatermarkEnabled)) {
								err = DataModel::Decode(reader, watermarkEnabled);
							} else if (__context_tag ==
								   to_underlying(Fields::kOSDEnabled)) {
								err = DataModel::Decode(reader, OSDEnabled);
							} else if (__context_tag ==
								   to_underlying(Fields::kReferenceCount)) {
								err = DataModel::Decode(reader, referenceCount);
							}

							ReturnErrorOnFailure(err);
						}
					}

				} // namespace VideoStreamStruct

				namespace SnapshotStreamStruct
				{
					CHIP_ERROR Type::Encode(TLV::TLVWriter &aWriter, TLV::Tag aTag) const
					{
						DataModel::WrappedStructEncoder encoder{ aWriter, aTag };
						encoder.Encode(to_underlying(Fields::kSnapshotStreamID),
							       snapshotStreamID);
						encoder.Encode(to_underlying(Fields::kImageCodec), imageCodec);
						encoder.Encode(to_underlying(Fields::kFrameRate), frameRate);
						encoder.Encode(to_underlying(Fields::kMinResolution), minResolution);
						encoder.Encode(to_underlying(Fields::kMaxResolution), maxResolution);
						encoder.Encode(to_underlying(Fields::kQuality), quality);
						encoder.Encode(to_underlying(Fields::kReferenceCount), referenceCount);
						encoder.Encode(to_underlying(Fields::kEncodedPixels), encodedPixels);
						encoder.Encode(to_underlying(Fields::kHardwareEncoder),
							       hardwareEncoder);
						encoder.Encode(to_underlying(Fields::kWatermarkEnabled),
							       watermarkEnabled);
						encoder.Encode(to_underlying(Fields::kOSDEnabled), OSDEnabled);
						return encoder.Finalize();
					}

					CHIP_ERROR DecodableType::Decode(TLV::TLVReader &reader)
					{
						detail::StructDecodeIterator __iterator(reader);
						while (true) {
							uint8_t __context_tag = 0;
							CHIP_ERROR err = __iterator.Next(__context_tag);
							VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV,
									    CHIP_NO_ERROR);
							ReturnErrorOnFailure(err);

							if (__context_tag == to_underlying(Fields::kSnapshotStreamID)) {
								err = DataModel::Decode(reader, snapshotStreamID);
							} else if (__context_tag ==
								   to_underlying(Fields::kImageCodec)) {
								err = DataModel::Decode(reader, imageCodec);
							} else if (__context_tag == to_underlying(Fields::kFrameRate)) {
								err = DataModel::Decode(reader, frameRate);
							} else if (__context_tag ==
								   to_underlying(Fields::kMinResolution)) {
								err = DataModel::Decode(reader, minResolution);
							} else if (__context_tag ==
								   to_underlying(Fields::kMaxResolution)) {
								err = DataModel::Decode(reader, maxResolution);
							} else if (__context_tag == to_underlying(Fields::kQuality)) {
								err = DataModel::Decode(reader, quality);
							} else if (__context_tag ==
								   to_underlying(Fields::kReferenceCount)) {
								err = DataModel::Decode(reader, referenceCount);
							} else if (__context_tag ==
								   to_underlying(Fields::kEncodedPixels)) {
								err = DataModel::Decode(reader, encodedPixels);
							} else if (__context_tag ==
								   to_underlying(Fields::kHardwareEncoder)) {
								err = DataModel::Decode(reader, hardwareEncoder);
							} else if (__context_tag ==
								   to_underlying(Fields::kWatermarkEnabled)) {
								err = DataModel::Decode(reader, watermarkEnabled);
							} else if (__context_tag ==
								   to_underlying(Fields::kOSDEnabled)) {
								err = DataModel::Decode(reader, OSDEnabled);
							}

							ReturnErrorOnFailure(err);
						}
					}

				} // namespace SnapshotStreamStruct

				namespace SnapshotCapabilitiesStruct
				{
					CHIP_ERROR Type::Encode(TLV::TLVWriter &aWriter, TLV::Tag aTag) const
					{
						DataModel::WrappedStructEncoder encoder{ aWriter, aTag };
						encoder.Encode(to_underlying(Fields::kResolution), resolution);
						encoder.Encode(to_underlying(Fields::kMaxFrameRate), maxFrameRate);
						encoder.Encode(to_underlying(Fields::kImageCodec), imageCodec);
						encoder.Encode(to_underlying(Fields::kRequiresEncodedPixels),
							       requiresEncodedPixels);
						encoder.Encode(to_underlying(Fields::kRequiresHardwareEncoder),
							       requiresHardwareEncoder);
						return encoder.Finalize();
					}

					CHIP_ERROR DecodableType::Decode(TLV::TLVReader &reader)
					{
						detail::StructDecodeIterator __iterator(reader);
						while (true) {
							uint8_t __context_tag = 0;
							CHIP_ERROR err = __iterator.Next(__context_tag);
							VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV,
									    CHIP_NO_ERROR);
							ReturnErrorOnFailure(err);

							if (__context_tag == to_underlying(Fields::kResolution)) {
								err = DataModel::Decode(reader, resolution);
							} else if (__context_tag ==
								   to_underlying(Fields::kMaxFrameRate)) {
								err = DataModel::Decode(reader, maxFrameRate);
							} else if (__context_tag ==
								   to_underlying(Fields::kImageCodec)) {
								err = DataModel::Decode(reader, imageCodec);
							} else if (__context_tag ==
								   to_underlying(Fields::kRequiresEncodedPixels)) {
								err = DataModel::Decode(reader, requiresEncodedPixels);
							} else if (__context_tag ==
								   to_underlying(Fields::kRequiresHardwareEncoder)) {
								err = DataModel::Decode(reader,
											requiresHardwareEncoder);
							}

							ReturnErrorOnFailure(err);
						}
					}

				} // namespace SnapshotCapabilitiesStruct

				namespace RateDistortionTradeOffPointsStruct
				{
					CHIP_ERROR Type::Encode(TLV::TLVWriter &aWriter, TLV::Tag aTag) const
					{
						DataModel::WrappedStructEncoder encoder{ aWriter, aTag };
						encoder.Encode(to_underlying(Fields::kCodec), codec);
						encoder.Encode(to_underlying(Fields::kResolution), resolution);
						encoder.Encode(to_underlying(Fields::kMinBitRate), minBitRate);
						return encoder.Finalize();
					}

					CHIP_ERROR DecodableType::Decode(TLV::TLVReader &reader)
					{
						detail::StructDecodeIterator __iterator(reader);
						while (true) {
							uint8_t __context_tag = 0;
							CHIP_ERROR err = __iterator.Next(__context_tag);
							VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV,
									    CHIP_NO_ERROR);
							ReturnErrorOnFailure(err);

							if (__context_tag == to_underlying(Fields::kCodec)) {
								err = DataModel::Decode(reader, codec);
							} else if (__context_tag ==
								   to_underlying(Fields::kResolution)) {
								err = DataModel::Decode(reader, resolution);
							} else if (__context_tag ==
								   to_underlying(Fields::kMinBitRate)) {
								err = DataModel::Decode(reader, minBitRate);
							}

							ReturnErrorOnFailure(err);
						}
					}

				} // namespace RateDistortionTradeOffPointsStruct

				namespace AudioCapabilitiesStruct
				{
					CHIP_ERROR Type::Encode(TLV::TLVWriter &aWriter, TLV::Tag aTag) const
					{
						DataModel::WrappedStructEncoder encoder{ aWriter, aTag };
						encoder.Encode(to_underlying(Fields::kMaxNumberOfChannels),
							       maxNumberOfChannels);
						encoder.Encode(to_underlying(Fields::kSupportedCodecs),
							       supportedCodecs);
						encoder.Encode(to_underlying(Fields::kSupportedSampleRates),
							       supportedSampleRates);
						encoder.Encode(to_underlying(Fields::kSupportedBitDepths),
							       supportedBitDepths);
						return encoder.Finalize();
					}

					CHIP_ERROR DecodableType::Decode(TLV::TLVReader &reader)
					{
						detail::StructDecodeIterator __iterator(reader);
						while (true) {
							uint8_t __context_tag = 0;
							CHIP_ERROR err = __iterator.Next(__context_tag);
							VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV,
									    CHIP_NO_ERROR);
							ReturnErrorOnFailure(err);

							if (__context_tag ==
							    to_underlying(Fields::kMaxNumberOfChannels)) {
								err = DataModel::Decode(reader, maxNumberOfChannels);
							} else if (__context_tag ==
								   to_underlying(Fields::kSupportedCodecs)) {
								err = DataModel::Decode(reader, supportedCodecs);
							} else if (__context_tag ==
								   to_underlying(Fields::kSupportedSampleRates)) {
								err = DataModel::Decode(reader, supportedSampleRates);
							} else if (__context_tag ==
								   to_underlying(Fields::kSupportedBitDepths)) {
								err = DataModel::Decode(reader, supportedBitDepths);
							}

							ReturnErrorOnFailure(err);
						}
					}

				} // namespace AudioCapabilitiesStruct

				namespace AudioStreamStruct
				{
					CHIP_ERROR Type::Encode(TLV::TLVWriter &aWriter, TLV::Tag aTag) const
					{
						DataModel::WrappedStructEncoder encoder{ aWriter, aTag };
						encoder.Encode(to_underlying(Fields::kAudioStreamID), audioStreamID);
						encoder.Encode(to_underlying(Fields::kStreamUsage), streamUsage);
						encoder.Encode(to_underlying(Fields::kAudioCodec), audioCodec);
						encoder.Encode(to_underlying(Fields::kChannelCount), channelCount);
						encoder.Encode(to_underlying(Fields::kSampleRate), sampleRate);
						encoder.Encode(to_underlying(Fields::kBitRate), bitRate);
						encoder.Encode(to_underlying(Fields::kBitDepth), bitDepth);
						encoder.Encode(to_underlying(Fields::kReferenceCount), referenceCount);
						return encoder.Finalize();
					}

					CHIP_ERROR DecodableType::Decode(TLV::TLVReader &reader)
					{
						detail::StructDecodeIterator __iterator(reader);
						while (true) {
							uint8_t __context_tag = 0;
							CHIP_ERROR err = __iterator.Next(__context_tag);
							VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV,
									    CHIP_NO_ERROR);
							ReturnErrorOnFailure(err);

							if (__context_tag == to_underlying(Fields::kAudioStreamID)) {
								err = DataModel::Decode(reader, audioStreamID);
							} else if (__context_tag ==
								   to_underlying(Fields::kStreamUsage)) {
								err = DataModel::Decode(reader, streamUsage);
							} else if (__context_tag ==
								   to_underlying(Fields::kAudioCodec)) {
								err = DataModel::Decode(reader, audioCodec);
							} else if (__context_tag ==
								   to_underlying(Fields::kChannelCount)) {
								err = DataModel::Decode(reader, channelCount);
							} else if (__context_tag ==
								   to_underlying(Fields::kSampleRate)) {
								err = DataModel::Decode(reader, sampleRate);
							} else if (__context_tag == to_underlying(Fields::kBitRate)) {
								err = DataModel::Decode(reader, bitRate);
							} else if (__context_tag == to_underlying(Fields::kBitDepth)) {
								err = DataModel::Decode(reader, bitDepth);
							} else if (__context_tag ==
								   to_underlying(Fields::kReferenceCount)) {
								err = DataModel::Decode(reader, referenceCount);
							}

							ReturnErrorOnFailure(err);
						}
					}

				} // namespace AudioStreamStruct

				namespace VideoSensorParamsStruct
				{
					CHIP_ERROR Type::Encode(TLV::TLVWriter &aWriter, TLV::Tag aTag) const
					{
						DataModel::WrappedStructEncoder encoder{ aWriter, aTag };
						encoder.Encode(to_underlying(Fields::kSensorWidth), sensorWidth);
						encoder.Encode(to_underlying(Fields::kSensorHeight), sensorHeight);
						encoder.Encode(to_underlying(Fields::kMaxFPS), maxFPS);
						encoder.Encode(to_underlying(Fields::kMaxHDRFPS), maxHDRFPS);
						return encoder.Finalize();
					}

					CHIP_ERROR DecodableType::Decode(TLV::TLVReader &reader)
					{
						detail::StructDecodeIterator __iterator(reader);
						while (true) {
							uint8_t __context_tag = 0;
							CHIP_ERROR err = __iterator.Next(__context_tag);
							VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV,
									    CHIP_NO_ERROR);
							ReturnErrorOnFailure(err);

							if (__context_tag == to_underlying(Fields::kSensorWidth)) {
								err = DataModel::Decode(reader, sensorWidth);
							} else if (__context_tag ==
								   to_underlying(Fields::kSensorHeight)) {
								err = DataModel::Decode(reader, sensorHeight);
							} else if (__context_tag == to_underlying(Fields::kMaxFPS)) {
								err = DataModel::Decode(reader, maxFPS);
							} else if (__context_tag == to_underlying(Fields::kMaxHDRFPS)) {
								err = DataModel::Decode(reader, maxHDRFPS);
							}

							ReturnErrorOnFailure(err);
						}
					}

				} // namespace VideoSensorParamsStruct
			} // namespace Structs
		} // namespace CameraAvStreamManagement
	} // namespace Clusters
} // namespace app
} // namespace chip
